package com.dev.toolkit.api;

import com.dev.toolkit.common.response.Result;
import com.dev.toolkit.domain.bo.GenerateCodeConfigBO;
import com.dev.toolkit.model.EntityPropertyConfig;
import com.dev.toolkit.service.IEntityPropertyConfigService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ZhuYouBin
 * @version 1.0.0
 * @date 2024-04-27 21:53:33.082543900
 * @description 实体属性配置表
 */
@RestController
@RequestMapping("/api/entity/property/config")
public class EntityPropertyConfigController {
    @Resource
    private IEntityPropertyConfigService entityPropertyConfigService;

    @GetMapping("/list")
    public Result<List<EntityPropertyConfig>> configList(String searchParam) {
        return Result.success(entityPropertyConfigService.getEntityPropertyConfigList(searchParam));
    }

    @PostMapping("/generateCode")
    public Result<String> generateCode(@RequestBody GenerateCodeConfigBO config) {
        return Result.success(entityPropertyConfigService.generateCode(config));
    }

    @GetMapping("/synchronization")
    public Result<Void> synchronizationData(String dsName) {
        entityPropertyConfigService.synchronizationData(dsName);
        return Result.<Void>success().message("数据同步成功，可能存在延迟，请重新查询列表数据！");
    }
}